import request from "@/utils/request";
//获取角色列表
export const getroles = (data) => {
  return request({
    method: "GET",
    url: "/roles",
    params: data,
  });
};
//添加
export const tianrole = (data) => {
  return request({
    method: "POST",
    url: "/roles",
    data,
  });
};
//编辑
export const editrole = (data) => {
  return request({
    method: "GET",
    url: `/roles/${data.id}`,
    data,
  });
};
//编辑提交

export const tianroleeatid = (data) => {
  return request({
    method: "PUT",
    url: `/roles/${data.id}`,
    data,
  });
};
//删除
export const getrolesshan = (id) => {
  return request({
    method: "DELETE",
    url: `/roles/${id}`,
    id,
  });
};

//删除权限
export const quanrolesshan = (data, id) => {
  return request({
    method: "DELETE",
    url: `/roles/${data}/rights/${id}`,
    data,
    id,
  });
};
//分配权限请求
export const quanrolesfen = () => {
  return request({
    method: "GET",
    url: `/rights/tree`,
  });
};

//角色授权
// roles/:roleId/rights
export const quanrolessou = (id, data) => {
  return request({
    method: "POST",
    url: `roles/${id}/rights`,
    id,
    data,
  });
};
